package com.example.computer_exam_training_sys.service.impl;

import com.example.computer_exam_training_sys.entity.AdminInfo;
import com.example.computer_exam_training_sys.mapper.AdminMapper;
import com.example.computer_exam_training_sys.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    public AdminMapper adminMapper;

    @Override
    public List<AdminInfo> getAdminList() {
        return adminMapper.getAdminList();
    }

    @Override
    public List<AdminInfo> searchAdmins(String name, String role, Integer status) {
        return adminMapper.searchAdmins(name, role, status);
    }

    @Override
    public AdminInfo getAdminById(Integer admin_id) {
        return adminMapper.getAdminById(admin_id);
    }

    @Override
    public boolean updateAdmin(AdminInfo adminInfo) {
        return adminMapper.updateAdmin(
                adminInfo.getRole(),
                adminInfo.getDepartment(),
                adminInfo.getPermissions(),
                adminInfo.getStatus(),
                adminInfo.getAdminId()
        ) > 0;
    }
}